<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
<!--    <div class="table-page-search-wrapper">-->
<!--      <a-form layout="inline">-->
<!--        <a-row :gutter="24">-->
<!--          <a-col :md="6" :sm="8">-->
<!--            <a-form-item label="订单号">-->
<!--              <j-input v-model="queryParam.contractId" placeholder="请输入订单号"></j-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :md="6" :sm="8">-->
<!--            <a-form-item label="手机号码">-->
<!--              <j-input v-model="queryParam.contactPhone" placeholder="请输入手机号码"></j-input>-->
<!--              &lt;!&ndash; <a-date-picker placeholder="请输入车型配置" v-model="queryParam.carTypeConfiguration"></a-date-picker> &ndash;&gt;-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :md="6" :sm="8">-->
<!--            <a-form-item label="车辆型号">-->
<!--              <j-input v-model="queryParam.brand" placeholder="请输入车辆型号"></j-input>-->
<!--              &lt;!&ndash; <a-date-picker placeholder="请输入车型配置" v-model="queryParam.carTypeConfiguration"></a-date-picker> &ndash;&gt;-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <template v-if="toggleSearchStatus">-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="车辆vin码">-->
<!--                <j-input v-model="queryParam.vin" placeholder="请输入车辆vin码"></j-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="车辆颜色">-->
<!--                <j-input v-model="queryParam.outsideColor" placeholder="请输入车辆颜色"></j-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="销售状态">-->
<!--                <a-radio-group v-model="queryParam.orderType">-->
<!--                  <a-radio :value="1">-->
<!--                    订单-->
<!--                  </a-radio>-->
<!--                  <a-radio :value="2">-->
<!--                    合同-->
<!--                  </a-radio>-->
<!--                </a-radio-group>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--          </template>-->
<!--          <a-col :md="6" :sm="8">-->
<!--            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden">-->
<!--              <a-button icon="search" type="primary" @click="searchQuery">查询</a-button>-->
<!--              <a-button-->
<!--                icon="reload"-->
<!--                style="margin-left: 8px"-->
<!--                type="primary"-->
<!--                @click="searchReset"-->
<!--              >重置</a-button>-->
<!--              <a style="margin-left: 8px" @click="handleToggleSearch">-->
<!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
<!--              </a>-->
<!--            </span>-->
<!--          </a-col>-->
<!--        </a-row>-->
<!--      </a-form>-->
<!--    </div>-->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!--      <a-button icon="plus" type="primary" @click="handleAdd2(1)">新增</a-button>-->
      <!--      &lt;!&ndash;      <a-button @click="handleAdd3" type="primary" icon="plus">新增牵引车挂车订单</a-button>&ndash;&gt;-->
      <!--      <a-button icon="download" type="primary" @click="handleExportXls('cxm-订单记录信息')">导出</a-button>-->
      <!--      <a-upload-->
      <!--        :action="importExcelUrl"-->
      <!--        :headers="tokenHeader"-->
      <!--        :multiple="false"-->
      <!--        :showUploadList="false"-->
      <!--        name="file"-->
      <!--        @change="handleImportExcel"-->
      <!--      >-->
      <!--        <a-button icon="import" type="primary">导入</a-button>-->
      <!--      </a-upload>-->
      <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
      <!--        <a-menu slot="overlay">-->
      <!--          <a-menu-item key="1" @click="batchDel2">-->
      <!--            <a-icon type="delete"/>-->
      <!--            删除-->
      <!--          </a-menu-item>-->
      <!--        </a-menu>-->
      <!--        <a-button style="margin-left: 8px">-->
      <!--          批量操作-->
      <!--          <a-icon type="down"/>-->
      <!--        </a-button>-->
      <!--      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        bordered
        rowKey="id"
        size="middle"
        @change="handleTableChange"
      >
        <span slot="operation" slot-scope="text, record">
          <a-button type="primary" @click="handleEdit4(record, 3)">审批</a-button>
          <!--          <a-button @click="handleEdit(record)" style="margin: 0 10px 0 ">修改</a-button>-->
          <!--          <a-button @click="showModal(record)">作废</a-button>-->
          <!--          <a-modal v-model="visible2" title="作废提示" @ok="getInfo(record)">-->
          <!--            <p>是否对该条记录进行作废？作废后将无法恢复！</p>-->
          <!--          </a-modal>-->
        </span>
        <span
          slot="filterDepositAttribute"
          slot-scope="depositAttribute"
        >{{ depositAttribute | filterDepositAttribute(depositAttribute) }}</span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <!-- <cxmOrderManager-modal ref="modalForm" @ok="modalFormOk"></cxmOrderManager-modal> -->
    <sales-register-model ref="modalForm" @ok="modalFormOk"></sales-register-model>
    <!--    <sales-regis-form-model ref="modalForm2" @ok="modalFormOk"></sales-regis-form-model>-->
    <cxm-order-manager-info-modal ref="cxmOrderManagerInfoModal"></cxm-order-manager-info-modal>
  </a-card>
</template>

<script>
import CxmOrderManagerModal from '../../cxm/modules/CxmOrderManagerModal.vue'
import CxmOrderManagerInfoModal from '../../cxm/modules/CxmOrderManagerInfoModal.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@/components/jeecg/JInput'
import moment from 'moment'
import SalesRegisterModel from '@/views/sales/salesManager/SalesRegisterModel'

export default {
  name: 'SalesRegister',
  mixins: [JeecgListMixin],
  components: {
    CxmOrderManagerModal,
    CxmOrderManagerInfoModal,
    SalesRegisterModel,
    JInput,
    moment
  },
  data() {
    return {
      dataSources: [],
      description: 'cxm-订单管理页面',
      visible: false,
      visible2: false,
      // 表头
      loading: '',
      columns: [
        {
          title: '订单号',
          align: 'center',
          dataIndex: 'contractId'
        },
        {
          title: '流程名（客户姓名-车辆品牌-车辆型号）',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        // {
        //   title: '销售状态',
        //   align: 'center',
        //   dataIndex: 'orderType'
        // },
        // {
        //   title: '交车地点',
        //   align: 'center',
        //   dataIndex: 'deliveryPlace'
        // },
        // {
        //   title: '应交付时间',
        //   align: 'center',
        //   dataIndex: 'deliveryTime'
        // },
        // {
        //   title: '订金(元)',
        //   align: 'center',
        //   dataIndex: 'deposit'
        // },
        // {
        //   title: '车辆销售价(元)',
        //   align: 'center',
        //   dataIndex: 'price'
        // },
        {
          title: '操作',
          dataIndex: 'operation',
          align: 'center',
          width: 140,
          scopedSlots: {
            customRender: 'operation'
          }
        }
      ],

      url: {
        list: '/sale/cxmSaleContractProcess/list?listType=' + 1,
        delete: '/cxm/cxmOrderManager/delete',
        deleteBatch: '/sale/cxmSaleOrderInfo/deleteOrderInfos',
        exportXlsUrl: 'cxm/cxmOrderManager/exportXls',
        importExcelUrl: 'cxm/cxmOrderManager/importExcel'
      }
    }
  },
  mounted() {
  },
  computed: {
    importExcelUrl: function() {
      return `${process.env.VUE_APP_BASE_API}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    close() {
      this.$emit('close')
      this.visible2 = false
    },
    showModal(record) {
      this.visible2 = true
      this.onSelectedRecordId = record.id

    },
    getInfo() {
      // this.axios.post('http://192.168.7.206:9099/cxmsystem/sale/cxmSaleOrderInfo/deleteOrderInfo?id=' + this.onSelectedRecordId
      this.axios.post('/sale/cxmSaleOrderInfo/deleteOrderInfo?id=' + this.onSelectedRecordId
      ).then(res => {
        let rs = res.result
        console.log(rs)
        this.close()
        this.loadData()
      }).catch(err => {
        // this.expRoute("2",err.message)
      })
    }
  },
  filters: {
    filterTime(time) {
      return moment(time).format('YYYY-MM-DD')
    },
    filterDepositAttribute(depositAttribute) {
      switch (depositAttribute) {
        case '1':
          return '可退'
          break
        case '2':
          return '不可退'
          break
        case '3':
          return '有条件可退'
          break
      }
    }
  }
}
</script>
<style scoped>
@import "~@assets/less/common.less";
</style>
